<template>
  <div>
    <h3>商品详情</h3>
    <el-card>
      <el-form>
        <el-form-item label="商品名称">
          <el-input v-model="this.list.name"></el-input>
        </el-form-item>
        <el-form-item label="商品描述">
          <el-input v-model="this.list.subtitle"></el-input>
        </el-form-item>
        <el-form-item label="商品状态">
          <el-button type="success" v-if="this.list.status == 2"
            >在售</el-button
          >
          <el-button type="info" v-if="this.list.status == 1">已下架</el-button>
        </el-form-item>
        <el-form-item label="所属分类">
          <el-select v-model="user" placeholder="请选择">
            <el-option
              v-for="(item, index) in one"
              :key="index"
              :value="item.name"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="商品价格">
          <el-input v-model="this.list.price"></el-input>
        </el-form-item>
        <el-form-item label="商品库存">
          <el-input v-model="this.list.stock"></el-input>
        </el-form-item>

        <el-form-item label="商品图片">
          <img :src="this.list.imageHost + this.list.mainImage" alt="" />
        </el-form-item>
        <el-form-item label="商品详情">
          <el-input v-model="this.list.subtitle"></el-input>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>


<script>
import { goodesid, son } from "../../../util/http";
export default {
  name: "",
  components: {},
  props: [],
  data() {
    return {
      list: [],
      //一级分类
      one: [],
      user: "",
    };
  },
  mounted() {
    this.getlist(), this.getone();
  },
  methods: {
    async getlist() {
      // let id=JSON.parse(this.$route.query.id).id
      let id = this.$route.params.id;
      console.log(id);
      const { data: res } = await goodesid(
        `/api/manage/product/detail.do?productId=${id}`
      );
      console.log(res);
      if (res.status !== 0) return this.$message.error("请求失败");
      this.list = res.data;
    },
    async getone() {
      const { data: res } = await son(
        `/api/manage/category/get_category.do?categoryId=0`
      );
      console.log(res);
      if (res.status !== 0) return this.$message.error("请求失败");
      this.one = res.data;
    },
  },
  computed: {},
  watch: {},
  created() {},
};
</script>


<style scoped>
/* .el-row {
  margin-bottom: 20px;
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
*/
img{
    width: 50px;
    height: 50px;
} 
</style>